package main

import (
	"fmt"
	"math/rand"
)

// ~~~~~~~~~~~~~第一题~~~~~~~~~~~~~~~~~~~~~~~
// s1 := make([]int, 3,4)
// s2 := append(s1,1)
// s1	[0,0,0] len:3 cap:4
// s2	[0,0,0,1] len:4 cap:4
// s1修改一个元素会影响s2，s2修改前三个元素会影响s1，修改最后一个不会影响
// s2再增加一个元素，s2的底层数组会扩容cap：8
func work2() {
	s1 := [...]int{1, 4, 9, 16, 2, 5, 10, 15}
	fmt.Printf("%T\n", s1)
	s2 := make([]int, 0, 10)
	for k, _ := range s1 {
		if k+1 == len(s1) {
			s2 = append(s2, s1[k]+s1[k-1])
			break
		}

		s2 = append(s2, s1[k]+s1[k+1])
	}
	fmt.Printf("%v\n", s2)
}
func work3() {

	s1 := make([]int, 0, 100)
	for i := 0; i < 100; i++ {
		x := rand.Intn(201) - 100
		s1 = append(s1, x)
	}
	fmt.Printf("%+v\n", s1)
	for i := 0; i < len(s1)-1; i++ {
		for j := 0; j < len(s1)-1-i; j++ {
			if s1[j] < s1[j+1] {
				s1[j], s1[j+1] = s1[j+1], s1[j]
			}
			// fmt.Printf("%+v\n", s1)
		}
	}

}
func main() {
	work3()
}

// 批改意见
// 1. 倒序输出的同时，还要统计重复次数，考察的是map知识点，尝试自己完成一下